// pages/new-pages/my-employee-detail/my-employee-detail.js
const app = getApp();
import Toast from '../../../component/toast/toast';
import { formatAmount } from '../../../utils/util.js';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        orderId:'',
        employeeData:{}
    },
    getMyEmployeeDetail(){
        wx.showLoading({
            title: '加载中...',
            mask: true
        });
        let that = this;
        wx.request({
            url: app.globalData.serverAddress.getMyEmployeeDetail,
            data: {
                currentUserInfoId:app.userInfo.Id,
                orderId: that.data.orderId
            },
            header: {
                'Authorization': "Bearer " + app.globalData.token
            },
            method: 'GET',
            success: function(res) {
                console.log("getMyEmployeeDetail response" , res);
                if(res.statusCode == 200){
                    if(res.data.CodeStatus == 20000){
                        let obj = res.data.BodyContent;
                        obj._amount = formatAmount(obj.OrderAmount);
                        that.setData({
                            employeeData: obj
                        });
                    }else{
                        Toast(res.data.Message);
                    }
                }
            },
            fail: function (res) { console.log("getMyEmployeeDetail fail" , res);},
            complete: function(res) {wx.hideLoading()},
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        console.log(options.orderId);
        if (options.orderId){
            this.setData({
                orderId:options.orderId
            });
            this.getMyEmployeeDetail();
        }
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})